home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC17Darts / Darts.asm / UMenu.asm < prev    next >
Encoding:
Assembly Source File  |  1990-06-24  |  6.6 KB  |  276 lines  |  [TEXT/pdos]

  1. ***********************************************************************
  2. *
  3. * darts umenu.asm -- Version 3.0 
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements 
  12. * menus in the program.
  13. *
  14. ***********************************************************************
  15.  
  16.                case on
  17.  
  18.                copy 2/ainclude/e16.types
  19.                copy 2/ainclude/e16.event
  20.                copy darts.equ
  21.  
  22.                mcopy macros/umenu.macros
  23.  
  24.                longi on
  25.                longa on
  26.  
  27. ***********************************************************************
  28. *
  29. * doAboutItem
  30. *
  31. * Calls AlertWindow to display the about box.  The result is ignored.
  32. *
  33. doAboutItem    start
  34.  
  35.                pha
  36.                pea refIsResource*2
  37.                PushLong #0
  38.                PushLong #1
  39.                _AlertWindow
  40.                pla
  41.                rts
  42.  
  43.                end
  44.  
  45. ***********************************************************************
  46. *
  47. * doNewItem
  48. *
  49. * Inits the current window for a new game.  Can be called in response
  50. * to a menu selection or button press.
  51. *
  52. doNewItem      start
  53.  
  54.                stz score                ;Zap the old scores.
  55.                stz score+2
  56.                pea Player1
  57.                jsr invalScore
  58.                pea Player2
  59.                jsr invalScore
  60.  
  61.                pea Player1              ;Clear the lists.
  62.                jsr clearList
  63.                pea Player2
  64.                jsr clearList
  65.  
  66.                ldy #26*2*2-2            ;Zap the crickett tables.
  67.                lda #0
  68. aa             sta crickettTables,y
  69.                dey
  70.                dey
  71.                bpl aa
  72.  
  73.                lda gameType
  74.                beq robinGame            ;That's all for Robin.
  75.  
  76.                ldy #25                  ;Zap the button titles.
  77. ab             phy                      ;Push YREG.
  78.  
  79.                pea Player1
  80.                phy                      ;Button to change.
  81.                jsr fixButtonTitle
  82.  
  83.                ply
  84.                phy                      ;Restore YREG.
  85.  
  86.                pea Player2
  87.                phy                      ;Button to change.
  88.                jsr fixButtonTitle
  89.  
  90.                ply                      ;Pull YREG.
  91.  
  92.                cpy #25
  93.                bne ac
  94.                ldy #21
  95. ac             dey
  96.                cpy #15
  97.                bcs ab
  98.  
  99.                stz weHaveAWinner
  100.  
  101. robinGame      rts
  102.  
  103.                end
  104.  
  105. ***********************************************************************
  106. *
  107. * doQuitItem
  108. *
  109. * Sets the global done flag to true in response to the quit menu time.
  110. * Can also be called in reponse to the quit button.
  111. *
  112. doQuitItem     start
  113.  
  114.                inc quitFlag             ;That's all folks.
  115.                rts
  116.  
  117.                end
  118.  
  119. ***********************************************************************
  120. *
  121. * doSwitchGames
  122. *
  123. * Switches from Robin to Crickett and back again.  This is called in
  124. * response to selections in the Game menu.  Note:  that if the selected
  125. * item is the current game, then nothing happens.
  126. *
  127. doSwitchGames  start
  128.  
  129.                DefineStack
  130.  
  131. saveDPage      word
  132. returnAddr     word
  133.  
  134. itemNum        word
  135.  
  136. ******************
  137.  
  138.                phd                      ;Save directPage register.
  139.                tsc                      ;Set directPage register.
  140.                tcd
  141.  
  142.                ldx #0                   ;Which game are we switching to?
  143.                lda itemNum
  144.                cmp #RobinGameItem
  145.                beq aa
  146.                inx
  147. aa             stx itemNum
  148.  
  149.                cpx gameType
  150.                beq isCurrentGame        ;Already playing that game.
  151.  
  152.                lda theWindow+2          ;Close the old window.
  153.                pha
  154.                lda theWindow
  155.                pha
  156.                _CloseWindow
  157.  
  158.                lda itemNum              ;Start up one or the other.
  159.                bne crickett
  160.                jsr startupRobinGame
  161.                bra newGame
  162.  
  163. crickett       jsr startupCrickettGame
  164.  
  165. newGame        lda itemNum
  166.                sta gameType
  167.                jsr doNewItem            ;Inits current window for new game.
  168.  
  169. isCurrentGame  anop
  170. exit           anop
  171.                pld                      ;Restore directPage register.
  172.                plx                      ;Save return address.
  173.                pla                      ;Remove passed parameters.
  174.                phx                      ;Restore return address and return.
  175.                rts
  176.  
  177.                end
  178.  
  179. ***********************************************************************
  180. *
  181. * doMenu
  182. *
  183. * This resonds to menu selections.  It is called by main event loop in 
  184. * response to all menu selctions (mouse and keyboard).
  185. *
  186. doMenu         start
  187.  
  188.                DefineStack
  189.  
  190. menuNum        word
  191. itemNum        word
  192.  
  193. saveDPage      word
  194. returnAddr     word
  195.  
  196. ******************
  197.  
  198.                phd                      ;Save directPage register.
  199.                pha                      ;Make space for locals.
  200.                pha
  201.                tsc                      ;Set directPage register.
  202.                tcd
  203.  
  204.                lda event+owmTaskData+2
  205.                sta menuNum
  206.                lda event+owmTaskData
  207.                sta itemNum
  208.  
  209.                cmp #AboutItem           ;Branch to correct thing
  210.                bne aa                   ;to do, and do it.
  211.                jsr doAboutItem
  212.                bra hilite
  213.  
  214. aa             cmp #NewItem
  215.                bne ab
  216.                jsr doNewItem
  217.                bra hilite
  218.  
  219. ab             cmp #QuitItem
  220.                bne ac
  221.                jsr doQuitItem
  222.                bra hilite
  223.  
  224. ac             cmp #RobinGameItem
  225.                beq ad
  226.                cmp #CrickettGameItem
  227.                bne hilite
  228.  
  229. ad             pei itemNum
  230.                jsr doSwitchGames
  231.  
  232. hilite         pea 0
  233.                pei menuNum
  234.                _HiliteMenu
  235.  
  236.                pla                      ;Remove local variable space.
  237.                pla
  238.                pld                      ;Restore directPage register.
  239.                rts
  240.  
  241.                end
  242.  
  243. ***********************************************************************
  244. *
  245. * setupMenus
  246. *
  247. * Creates the system menu bar with desk accessories.
  248. *
  249. setupMenus     start
  250.  
  251.                pha
  252.                pha
  253.                pea refIsResource
  254.                PushLong #1
  255.                PushLong #0
  256.                _NewMenuBar2
  257.                _SetSysBar
  258.  
  259.                PushLong #0
  260.                _SetMenuBar
  261.  
  262.                pea AppleMenuID
  263.                _FixAppleMenu
  264.  
  265.                pha
  266.                _FixMenuBar
  267.                pla
  268.  
  269.                _DrawMenuBar
  270.  
  271.                rts
  272.  
  273.                end
  274.  
  275.                END
  276.